import request from "@/api/request.js";


// 发帖
export function getPostTopics() {
    return request({
        url: '/user/post/topics',
        method: 'get',
    })
}
// 保存草稿
export function saveTheDraft(data) {
    return request({
        url: '/user/post/draft/save',
        method: 'post',
        data: data
    })
}
// 获取话题数据
export function postPost(data) {
    return request({
        url: '/user/post/post',
        method: 'post',
        data: data
    })
}


// 获取一篇文章的所有草稿
export function getDraftsByPostId(postId) {
    return request({
        url: '/user/post/drafts/list/' + postId,
        method: 'get',
    })
}

export function listAnyPostsByPage(lastPostId, pageSize) {
    return request({
        url: `/user/post/list/page?lastPostId=${lastPostId}&pageNum=${pageSize}`,
        method: 'get',
    })
}

export function toggleLikePost(postId, account) {
    const data = {
        postId: postId,
        account: account
    }
    return request({
        url: `/user/post/like/do`,
        method: 'post',
        data: data
    })

}
export function toggleCollectPost(postId, account, favoriteId) {
    const data = {
        postId: postId,
        account: account,
        favoriteId: favoriteId,
    }
    return request({
        url: `/user/post/favorite/collect`,
        method: 'post',
        data: data
    })

}

export function getThePostInfo(id, account) {
    return request({
        url: `/user/post/info/show?postId=${id}&account=${account}`,
        method: 'get',
    })
}

export function getThePostComments() {

}

// 根据账号获取收藏夹列表
export function ListFavorites(account, postId) {
    return request({
        url: `/user/post/favorites/list/${account}-${postId}`,
        method: 'get'
    })
}

// 创建一个新的收藏夹
export function createFavorite(name, account) {
    const data = {
        name: name,
        account: account
    }
    return request({
        url: `/user/post/favorite/create`,
        method: 'post',
        data: data
    })
}

export function listMyPost() {
    return request({
        url: `/user/post/list/mine`,
        method: 'get'
    })
}
// 获取帖子热度榜单
export function getHotPosts(account, limit = 10) {
    return request({
        url: `/user/post/hots?account=${account}&limit=${limit}`,
        method: 'get'
    })
}
